import { fastmockId } from "@/const/fastmockId";
import createErrorLog from "./createErrorLog";
import axios from 'axios';

// 全局的 axios 默认值
// axios.defaults.baseURL = 'https://api.example.com';
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

// 自定义实例默认值
// const instance = axios.create({
//     baseURL: 'https://api.example.com'
// });

// // Alter defaults after instance has been created
// instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;


export default axios;

export const mockAxios = axios.create({
    baseURL: `https://www.fastmock.site/mock/${fastmockId}/mockApi`


});

export const apiAxios = axios.create({
    // baseURL: `http://124.115.230.43:18080/openapi/v1/domain/mobile`
    baseURL:'http://wx.network-media.cn',
    maxRedirects: 0 // 防止自动重定向
    
});
// apiAxios.get('/getYouzanInfo', {
//     headers: {
//       'Access-Control-Allow-Origin': '*' // 或者特定的域名
//     }
//   });

// export const otherAxios = axios.create({
//     baseURL: 'http://itom.sxqc.com:18080/docp/gateway/api/v1/auth?module=builddaping'
// });


// 添加响应拦截器
apiAxios.interceptors.response.use(response => response, createErrorLog(['status', 'statusText']));
// apiAxios.defaults.withCredentials = true; // 表示跨域请求时是否需要使用凭证
// apiAxios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
// apiAxios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

